import 'package:flutter/material.dart';
import 'package:power_distribution_system/common/system_config.dart';
import 'package:power_distribution_system/model/font_scale.dart';
import 'package:power_distribution_system/utils/tools/screenutil_tool.dart';
import 'package:power_distribution_system/utils/widget/appbar_widget.dart';
import 'package:provider/provider.dart';

import 'components/create_container.dart';
import 'methods/tips_displayed.dart';

class SettingzoomView extends StatefulWidget {
  @override
  SettingzoomViewState createState() => new SettingzoomViewState();
}

class SettingzoomViewState extends State<SettingzoomView> {

  // 放大比例
  double _scale = 1.0;

  @override
  Widget build(BuildContext context) {
    double _w = MediaQuery.of(context).size.width;
    return Scaffold(
      appBar: AppBarWidget("字体显示大小", isShowRI: false).build(context),
      body: Consumer<FontScale>(
        builder: (context, model, child) {
          print(model.scale);

          return Center(
            child: Container(
              width: double.infinity,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    width: double.infinity,
                    alignment: Alignment.center,
                    child: Text("春夜喜雨",
                        style: TextStyle(
                            fontWeight: FontWeight.bold,
                            fontSize: SystemConfig.fs_title2
                        )
                    ),
                  ),
                  CreateContainer("好雨知时节，当春乃发生。"),
                  CreateContainer("随风潜入夜，润物细无声。"),
                  CreateContainer("野径云俱黑，江船火独明。"),
                  CreateContainer("晓看红湿处，花重锦官城。"),
                  Container(
                    width: ST.setw(600),
                    child: Slider(
                      value: model.scale == null ? 1.0 : model.scale,
                      activeColor: Theme.of(context).primaryColor,
                      inactiveColor: Theme.of(context).primaryColor.withOpacity(0.3),
                      min: 1.0,
                      max: 1.2,
                      divisions: 2,
                      label: "${ tipsDisplayed(model.scale == null ? 1.0 : model.scale) }",
                      onChanged: (value) {
                          model.setting(value);
                      },
                    ),
                  ),
                  Container(
                    width: ST.setw(600),
                    child: Text("当前字体设置：${ tipsDisplayed(model.scale == null ? 1.0 : model.scale) }",textAlign: TextAlign.center),
                  )
                ],
              ),
            ),
          );
        },
      ),
    );
  }


  @override
  void initState() {
    super.initState();
  }

}